<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../CSS/shop.css">

</head>


<body>
    <header></header>
    <div class="box">
        <div class="modd-box">
            <!-- //左边 -->
            <div class="modd-box-left">
                <!-- <ul>
                    <li class="mm">
                        <a href=""><img src="../img/687f13ca980ae047a4c508318be79c41 (1).jpg" alt=""></a>
                    </li>
                    <li class="mm">
                        <a href=""><img src="../img/687f13ca980ae047a4c508318be79c41 (1).jpg" alt=""></a>
                    </li>
                    <li class="mm">
                        <a href=""><img src="../img/687f13ca980ae047a4c508318be79c41 (1).jpg" alt=""></a>
                    </li>
                    <li class="mm">
                        <a href=""><img src="../img/687f13ca980ae047a4c508318be79c41 (1).jpg" alt=""></a>
                    </li>
                </ul> -->
            </div>
            <!-- //放大镜 -->
            <div id="small-box">
                <div id="mask"></div>
            </div>
            <div id="big-box"></div>
            <!-- //右边 -->

        </div>
        <div class="modd-box-right">
            <div class="modd-box-right-top">
                <p>篮球鞋</p>
                <h3 style=" font-size: 25px;line-height: 40px;font-weight: normal;">安踏男鞋海沃德2代秋季新款专业中帮实战耐磨球鞋2021新款</h3>
                <p id="goodsId">款号:112141105</p>
                <p>￥699.00</p>
            </div>
            <div class="modd-box-right-buttom">
                <div class="moddyy">
                    <ul class="color_list J_color_list">
                        <!-- <li class="color_code current"><img title="黑/体育红/银色" src="https://img.fishfay.com/shopgoods/1/112141105/112141105-1-1/327499e6ec610ccfae9dc45853c8415e.jpg?x-image-process=image/resize,w_80,h_80" class="loading"></li>
                    <li class="color_code"><img title="象牙白/黑/荧光艳红" src="https://img.fishfay.com/shopgoods/1/112141105/112141105-4-1/687f13ca980ae047a4c508318be79c41.jpg?x-image-process=image/resize,w_80,h_80" class="loading"></li>
                    <li class="color_code"><img title="土壤棕/鹅掌黄/象牙白" src="https://img.fishfay.com/shopgoods/1/112141105/112141105-2-1/32dabd21ab54caf89acb598489dbaf96.jpg?x-image-process=image/resize,w_80,h_80" class="loading"></li> -->
                    </ul>
                </div>
                <div class="box-tup">
                    <div class="box-tup-1">
                        <span>尺码</span>
                        <input id="selectSize" type="text" placeholder="请选择尺码" readonly="readonly">
                        <i class="icon-triangle-right"></i>
                        <i class="line"></i>
                        <div class="tanchu">
                            <h4 class="t1">请选择符合您的码数</h4>
                            <div class="popup-panel-body J_size_list">
                                <ul class="current">
                                    <li title="39" class="color_sku">
                                        <a>39</a>
                                    </li>
                                    <li title="40" class="color_sku">
                                        <a>40</a>
                                    </li>
                                    <li title="41" class="color_sku">
                                        <a>41</a>
                                    </li>
                                    <li title="42" class="color_sku">
                                        <a>42</a>
                                    </li>
                                    <li title="42.5" class="color_sku">
                                        <a>42.5</a>
                                    </li>
                                    <li title="43" class="color_sku">
                                        <a>43</a>
                                    </li>
                                    <li title="44" class="color_sku">
                                        <a>44</a>
                                    </li>
                                    <li title="44.5" class="color_sku">
                                        <a>44.5</a>
                                    </li>
                                    <li title="45" class="color_sku">
                                        <a>45</a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="box-tup-1">
                        <span>数量</span>
                        <input id="selectSize" type="text" value="1">
                        <i class="icon-triangle-right"></i>
                        <i class="line"></i>
                    </div>

                </div>
                <div class="ywq">
                    <span>领取优惠券</span>
                </div>
                <div class="kuang">
                    <a href="###" class="btn">加入购物车</a>
                    <a href="" class="btn-2">结算</a>
                </div>
            </div>
        </div>
    </div>
    </div>
    <footer></footer>
</body>

</html>
<script src="../js/shop.js"></script>
<script>
    let oSmallBox = document.querySelector("#small-box");
    let oBigBox = document.querySelector("#big-box");
    let oMask = document.querySelector("#mask");
    let oMm = document.getElementsByClassName(".mm")

    let mf = new Magnifier(oSmallBox, oBigBox, oMask, oMm);
</script>
<script src="../jQuery.js "></script>
<script src="../goodsAndShoppingCart/js/cookieTools.js"></script>
<script>
    $("header ").load("head.html ");
    $("footer ").load("footer.html ");
</script>
<script>
    let [, goodsId] = location.search.substring(1).split("=");
    console.log(goodsId)
    $.get('../goodsAndShoppingCart/getGoodsInfo.php', {
        goodsId: goodsId
    }, function(data) {
        let as = data.goodsId
        $("#small-box").css({
            backgroundImage: `url(${data.goodsImg})`
        })
        $("#big-box").css({
            backgroundImage: `url(${data.goodsImg})`
        })
        $("#selectSize").val(
            "1"
        )
        let htmlStr = `
        <ul>
                    <li class="mm">
                        <a href=""><img src="${data.beiyong1}"alt=""></a>
                    <li class="mm">
                        <a href=""><img src="${data.beiyong2}"alt=""></a>
                    </li>
                    <li class="mm">
                        <a href=""><img src="${data.beiyong3}"alt=""></a>
                    </li>
                    <li class="mm">
                        <a href=""><img src="${data.beiyong4}"alt=""></a>
                    </li>
                </ul>`;

        $(".modd-box-left").html(htmlStr)
        let htmlStr1 = `
        <div id="mask"></div>`
        $(".small-box").html(htmlStr1)
        let htmlStr2 = `
        <p>篮球鞋</p>
                <h3 style=" font-size: 25px;line-height: 40px;font-weight: normal;">${data.goodsDesc}</h3>
                 <p id="goodsId">款号：${data.goodsId}</p>
                <p>￥${data.goodsPrice}.00</p>
                `
        $(".modd-box-right-top").html(htmlStr2)
        $(".small-box").html(htmlStr1)
        let htmlStr3 = `

                    <li class="color_code"><img title="" src="${data.beiyong5}" class="loading"></li>
                    <li class="color_code"><img title="" src="${data.beiyong6}" class="loading"></li>
                    <li class="color_code"><img title="" src="${data.beiyong7}" class="loading"></li>
                `
        $(".moddyy").html(htmlStr3)
        addcar(document.getElementById("selectSize").value, goodsId);
    }, "json")

    let Ousername = getCookie("username");
    // let ogoodsCount = document.getElementById("selectSize").value

    function addcar(ogoodsCount, goodsId) {
        console.log(ogoodsCount, goodsId)
        $(".btn").click(function() {
            let xhr = new XMLHttpRequest();
            xhr.open("post", "../goodsAndShoppingCart/addShoppingCart.php", true);
            xhr.onreadystatechange = function() {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    if (xhr.responseText == "1") {
                        location.href = "gwc.html";
                        console.log("12345")
                    } else {
                        // document.getElementById("msg").innerHTML = "登录失败,用户名或者密码错误";
                    }
                }
            }

            xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

            let str = "goodsId=" + goodsId + "&goodsCount=" + ogoodsCount + "&vipName=" + Ousername
                // console.log(str)
            xhr.send(str);

        })
    }
</script>